package com.qasystem.qa.core.constants;

import com.qasystem.qa.core.base.BaseEnum;

import java.util.HashMap;
import java.util.Map;

public enum BaseEnums implements BaseEnum<String, String> {
    SUCCESS("request.success", "请求成功"),
    LOGIN_SUCCESS ("login.success", "登陆成功"),
    LOGIN_FAILURE ("login.failure", "登陆失败"),
    FAILURE("request.failure", "请求失败"),

    OPERATION_SUCCESS("operation.success", "操作成功"),

    OPERATION_FAILURE("operation.failure", "操作失败"),

    ERROR("system.error", "系统异常"),

    NOT_FOUND("not_found", "请求资源不存在"),

    FORBIDDEN("forbidden", "无权限访问"),

    LOGOUT_SUCCESS ("logout.success", "注销成功"),
    LOGOUT_FAILURE ("logout.failure", "注销失败"),

    VERSION_NOT_MATCH("record_not_exists_or_version_not_match", "记录版本不存在或不匹配"),

    PARAMETER_NOT_NULL("parameter_not_be_null", "参数不能为空");

    private String code;
    private String desc;
    private static Map<String ,String> allMap = new HashMap<>();

    BaseEnums (String code, String desc) {
        this.code = code;
        this.desc =desc;
    }


    @Override
    public String code() {
        return this.code;
    }

    @Override
    public String desc() {
        return this.desc;
    }
    public String desc(String code) {
        return allMap.get(code);
    }
}
